package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by larahy on 25/04/2014.
 */
public class User {
    String name;
    String email;
    String password;
    Integer membershipNo;
    boolean loggedIn = false;
    private Librarian librarian;

    public User (String aName, String anEmail, String aPassword, Integer aMembershipNo, Librarian aLibrarian) {
        name = aName;
        email = anEmail;
        password = aPassword;
        membershipNo = aMembershipNo;
        librarian = aLibrarian;
    }

    public User() {
    }

    public Librarian getLibrarian() {
        return librarian;
    }

//    void login(Integer aMembershipNo, String passwordEntered) throws Exception {
//        if (passwordEntered.equals(password) && aMembershipNo.equals(membershipNo)) {
//            loggedIn = true;
//            return;
//        }
//        throw new Exception("Incorrect Membership Number or Password");
//    }
//
//    void logout() {
//        loggedIn = false;
//    }

    String checkout(String title) throws Exception {
        if(loggedIn == true) {
            return librarian.checkoutRentable(title, this);
        }
        throw new Exception("You must login before proceeding");
    }

    String returnItem(String title) throws Exception {
        if(loggedIn == true) {
            return librarian.returnRentable(title, this);
        }
        throw new Exception("You must login before proceeding");
    }
}


//String output = phoneNumber.replaceAll("(\\d{3})(\\d{3})(\\d{4})", "($1) $2-$3");